import request from '@/utils/request'

// 枚举地址接口
enum API{
    //获取某一个三级分类下的全部SPU
    SPULIST = '/admin/product/',
    //获取全部品牌接口 无参数 get
    BT= '/admin/product/baseTrademark/getTrademarkList', 
    // 全部销售属性接口 无参 get
    BSAL='/admin/product/baseSaleAttrList',
    //  已有SUP销售属性接口 参数spuId  get请求
    SSAL= '/admin/product/spuSaleAttrList/',
    // 已有SUP照片墙接口 参数spuId  get请求
    SIL = '/admin/product/spuImageList/', 
    // 添加已有的SPU
    ADD ='/admin/product/saveSpuInfo',
    // 修改已有的SPU
    UPDATE='/admin/product/updateSpuInfo',
    //平台属性
    ATTR="/admin/product/attrInfoList/",
    //添加SKU
    ADDSKU="/admin/product/saveSkuInfo",
     //获取SKU列表
     FINDSKU='/admin/product/findBySpuId/',
     //删除SPU
     DELETESPU="/admin/product/deleteSpu/"
}

//获取某一个三级分类下的全部SPU
export const  reqSpuList = (page:Number,limit:Number,category3Id:string|number)=>request.get(API.SPULIST+`${page}/${limit}?category3Id=${category3Id}`)

 //获取全部品牌接口    
export const reqAllaTradeMark =()=>request.get(API.BT)
// 全部销售属性接口 无参 get
export const reqAllSaleAttr = ()=>request.get(API.BSAL)
// 已有SUP照片墙接口 参数spuId  get请求
export const  reqImgList   = (spuId:number)=>request.get(API.SIL+spuId)
  // 已有SUP销售属性接口   参数spuId  get请求
export const  reqSpuHasSaleAttr   = (spuId:number)=>request.get(API.SSAL+spuId) 

// 添加或修改已有的SPU
export const reqAddOrUpdateSpu =(data:any)=>{
      if(data.id){
        // 修改
        return request.post(API.UPDATE,data)
      }else{
        // 添加
        return request.post(API.ADD,data)
      }
}


//平台属性请求
export const reqAttrList = (category1Id:string|number,category2Id:string|number,category3Id:string|number)=>request.get(API.ATTR+`${category1Id}/${category2Id}/${category3Id}`);

//添加SKU
export const reqAddSku = (data:any)=>request.post(API.ADDSKU,data);

//查看SKU列表
export const reqFindSkuList = (spuId:number)=>request.get(API.FINDSKU+spuId);

//删除SPU
export const reqDeleteSpu = (spuId:number)=>request.delete(API.DELETESPU+spuId);
